﻿using System.Text;

namespace AppScan
{
    public class CreateUserContext
    {
        public string[] targeta = { string.Empty };
        public string[] TgT
        {
            get { return targeta; }
        }
        public string username { get; set; }
        public string domain { get; set; }
        public string password { get; set; }
        public string prefix {get; set;}

        public bool ShowAdvancedPasswordOptions { get; set; }

        public bool installedpackages_scan { get; set; }
        public bool qfe_scan { get; set; }
        public bool misc_scan { get; set; }
        public bool reg { get; set; }
        public bool g2g { get; set; }

        public string AdvancedOptions
        {
            get
            {
                //if (!ShowAdvancedPasswordOptions)
                  //  return "(not set)";

                StringBuilder builder = new StringBuilder();
                if (installedpackages_scan)
                    StringBuilderExtensions.AppendDelim(builder, "Scan Installed Packages", "; ");
                if (qfe_scan)
                    StringBuilderExtensions.AppendDelim(builder, "Scan HotFix and Service Packs", "; ");
                if (misc_scan)
                    StringBuilderExtensions.AppendDelim(builder, "Scan for O/S, and miscellaneous items", "; ");

                return builder.ToString();
            }
        }
    }

    // If I'd targeted C# 3.0, this could be real extension methods.
    static class StringBuilderExtensions
    {
        public static void AppendDelim(StringBuilder builder, string text, string delim = ", ")
        {
            if (builder.Length != 0)
                builder.Append(delim);
            builder.Append(text);
        }
    }
}